package com.ruoyi.web.controller.gasoline;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.GasolineExamine;
import com.ruoyi.service.IGasolineExamineService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2020-07-23
 */
@Controller
@RequestMapping("/ruoyi/examine")
public class ChildGasolineController extends BaseController
{
    private String prefix = "ruoyi/examine";

    @Autowired
    private IGasolineExamineService gasolineExamineService;

    @RequiresPermissions("ruoyi:examine:view")
    @GetMapping()
    public String examine()
    {
        return prefix + "/examine";
    }


    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:examine:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GasolineExamine gasolineExamine)
    {
        startPage();
        List<GasolineExamine> list = gasolineExamineService.selectGasolineExamineList(gasolineExamine);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:examine:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GasolineExamine gasolineExamine)
    {
        List<GasolineExamine> list = gasolineExamineService.selectGasolineExamineList(gasolineExamine);
        ExcelUtil<GasolineExamine> util = new ExcelUtil<GasolineExamine>(GasolineExamine.class);
        return util.exportExcel(list, "examine");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 下拉查询【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:examine:list")
    @PostMapping("/lists")
    @ResponseBody
    public List<GasolineExamine> lists(GasolineExamine gasolineExamine)
    {
        List<GasolineExamine> list = gasolineExamineService.selectGasolineExamineList(gasolineExamine);
        return list;
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:examine:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GasolineExamine gasolineExamine)
    {
        return toAjax(gasolineExamineService.insertGasolineExamine(gasolineExamine));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{eId}")
    public String edit(@PathVariable("eId") Long eId, ModelMap mmap)
    {
        GasolineExamine gasolineExamine = gasolineExamineService.selectGasolineExamineById(eId);
        mmap.put("gasolineExamine", gasolineExamine);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:examine:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GasolineExamine gasolineExamine)
    {
        return toAjax(gasolineExamineService.updateGasolineExamine(gasolineExamine));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:examine:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gasolineExamineService.deleteGasolineExamineByIds(ids));
    }
}
